package data;
import haxe.Public;

/**
 * ...
 * @author Felipe Manga
 */

class Message implements Public
{
	var id:Int;
	var messageClass:MessageClass;
	
	var issueTime:Dynamic;
	
	var projectId:Int;
	var tool:ToolData;
	var author:UserData;
	
	var message:String;
	var read:Bool;
	
	function renderPreview():String
	{
		var sender:String = "";
		if ( this.tool != null )
		{
			sender = this.tool.renderPreview();
		}
		else if ( this.author != null )
		{
			sender = this.author.renderPreview();
		}
		
		return "
		<div class='messagePreview'>
			<div class='sender'>
			"
			+ sender +
			"
			</div>
			<div class='message'>
			"
			+ (this.message.length>32?this.message.substr(0,32) + "...": this.message) +
			"
			</div>
		</div>
		";
	}
}